class Section < ActiveRecord::Base
  has_many :documents, :order=>'position'
    
  has_many :document_corrections
    
  belongs_to :collection
    
  acts_as_nested_set
    
  def search(query, options={})
    Document.search("(#{query}) && (sections_id:#{self.id})", options)
  end
  
  def lineage
    parents = []
    p = parent
    while p do
      parents << p
      p = p.parent
    end
    parents
  end
end
